package com.zsrt.java.day20161226.xww.demo4;

import java.util.Scanner;

public class Reverse {

	public static void reverse(int x) {

		if ((x / 10000 >= 1)&&(x/10000<10)) {
			int gewei = x % 10;
			int shiwei = x % 100 / 10;
			int baiwei = x % 1000 / 100;
			int qianwei = x % 10000 / 1000;
			int wanwei = x / 10000;
			int a[] = { wanwei, qianwei, baiwei, shiwei, gewei };
			System.out.println("五位数");
			for (int i = a.length - 1; i >= 0; i--) {
				System.out.print(a[i]);
			}
		}else if ((x / 1000 >= 1)&&(x / 1000 <10)) {
			int gewei = x % 10;
			int shiwei = x % 100 / 10;
			int baiwei = x % 1000 / 100;
			int qianwei = x % 10000 / 1000;
			int a[] = { qianwei, baiwei, shiwei, gewei };
			System.out.println("四位数");
			for (int i = a.length - 1; i >= 0; i--) {
				System.out.print(a[i]);
			}
		}else if ((x / 100 >= 1)&&(x / 100 < 10)) {

			int gewei = x % 10;
			int shiwei = x % 100 / 10;
			int baiwei = x % 1000 / 100;
			int a[] = { baiwei, shiwei, gewei };
			System.out.println("三位数");
			for (int i = a.length - 1; i >= 0; i--) {
				System.out.print(a[i]);
			}
		}else if ((x / 10 >= 1)&&(x / 10 <10)) {
			int gewei = x % 10;
			int shiwei = x % 100 / 10;
			int a[] = { shiwei, gewei };
			System.out.println("两位数");
			for (int i = a.length - 1; i >= 0; i--) {
				System.out.print(a[i]);
			}
		}else if((x/1>=1)&&(x/1<10)){
			int gewei = x % 10;
			int a[] = { gewei };
			System.out.println("一位数");
			for (int i = a.length - 1; i >= 0; i--) {
				System.out.print(a[i]);
			}
		}else{
			System.out.println("请输入1-99999范围的数");
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("输入一个数");
		int a = sc.nextInt();
		sc.close();
		reverse(a);
	}
}
